package com.zhz.common.enums;

import com.zhz.common.tool.mybatisplus.base.core.enums.EnumValueResolver;
import com.zhz.common.tool.mybatisplus.base.core.enums.IEnum;
import lombok.AllArgsConstructor;

@AllArgsConstructor
public enum ResultCode implements IEnum<Integer>, EnumValueResolver<ResultCode, Integer> {
    OK(true, 200, "请求/操作成功"),
    FAIL(false, 500, "请求成功但是服务异常"),
    UNAUTHORIZED(false, 401, "未登录或token已经失效"),
    FORBIDDEN(false, 403, "没有权限"),
    SERVER_ERROR(false, 500, "服务器异常"),
    REQUEST_ERROR(false, 400, "请求异常");
    //操作是否成功
    private final boolean success;
    private final Integer code;
    private final String message;

    /**
     * 是否成功
     */
    public Boolean getSuccess() {
        return this.success;
    }

    /**
     * 获取编码
     *
     * @return
     */
    @Override
    public Integer getCode() {
        return this.code;
    }

    /**
     * 获取描述
     *
     * @return
     */
    @Override
    public String getMessage() {
        return this.message;
    }
}